package com.qyhl.webtv.module_news.news.jlnews;


import com.qyhl.webtv.basiclib.utils.network.EasyHttp;
import com.qyhl.webtv.basiclib.utils.network.callback.SimpleCallBack;
import com.qyhl.webtv.basiclib.utils.network.exception.ApiException;
import com.qyhl.webtv.commonlib.entity.news.JLNewDetailBean;
import com.qyhl.webtv.module_news.common.NewsUrl;

public class JLNewsModel implements JLNewsContract.JLNewsModel {
    private JLNewsPresenter mPresenter;

    JLNewsModel(JLNewsPresenter mPresenter) {
        this.mPresenter = mPresenter;
    }

    @Override
    public void getDetail(String newsId) {

        EasyHttp.get(NewsUrl.JL_NEWS_DETAIL)
                .params("newsId", newsId)
                .execute(new SimpleCallBack<JLNewDetailBean>() {
                    @Override
                    public void onError(ApiException e) {
                        mPresenter.setError();
                    }

                    @Override
                    public void onSuccess(JLNewDetailBean jlNewDetailBean) {
                        mPresenter.setDetail(jlNewDetailBean);
                    }
                });

    }
}
